package com.allwees.bs.module.scm.transform;

import com.allwees.bs.core.modelbase.transform.ObjectTransformFactory;
import com.allwees.bs.module.scm.entity.ScmPickOrderSku;
import com.allwees.bs.module.scm.entity.ScmShippingOrderSku;
import com.allwees.core.common.constant.EStatus;

public class ScmPickOrderSkuToScmShippingOrderSkuTransformFactory extends ObjectTransformFactory<ScmPickOrderSku, ScmShippingOrderSku> {

    @Override
    public boolean match(Class<?> f, Class<?> t) {
        return f.getName().equals(ScmPickOrderSku.class.getName()) && t.getName().equals(ScmShippingOrderSku.class.getName());
    }

    @Override
    protected ScmShippingOrderSku create() {
        return new ScmShippingOrderSku();
    }

    @Override
    protected ScmShippingOrderSku transform(ScmPickOrderSku from, ScmShippingOrderSku target) {

        target = super.transform(from, target);

        target.setPickOrderSkuUuid(from.getUuid());
        target.setShippingQuantity(from.getShippingQuantity());

        return target;
    }

    @Override
    protected ScmShippingOrderSku perfect(ScmShippingOrderSku shippingOrderSku) {
        shippingOrderSku.setEStatus(EStatus.SCM_WAIT_ENTER);
        return shippingOrderSku;
    }
}
